package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.contract.CollectContract;
import com.xuxin.baby.model.CollectModel;

/**
 * Created by xu_xin
 * Created on 2020/11/4 0004
 * 收藏
 */
public class CollectPresenter implements CollectContract.Presenter {
    private final CollectModel model;
    private final CollectContract.View view;

    public CollectPresenter(CollectContract.View view) {
        this.view = view;
        model = new CollectModel();
    }

    @Override
    public void collect(String tenantId, String token, String memberId, String courseId) {
        if (null != model) {
            model.collect(this, tenantId, token, memberId, courseId);
        }
    }

    @Override
    public void deleteCollect(String tenantId, String token, String memberId, String courseId) {
        if (null != model) {
            model.deleteCollect(this, tenantId, token, memberId, courseId);
        }
    }

    @Override
    public void onCollectSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onCollectSuccess(baseBean);
        }
    }

    @Override
    public void onDeleteCollectSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onDeleteCollectSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}